package com.sentiment.strategy;

import org.bson.Document;

import com.sentiment.obj.Text;

public class TextManager {
	/**
	 * 返回一个Text内的字符总数
	 * 
	 * @param tx
	 *            传入的Text
	 * @return 字符总数
	 */
	public static int charactersAmount(Text tx) {
		int amount = 0;
		Document doc = tx.getContent();
		int paraAmount = doc.getInteger("paraAmount");
		for (int i = 1; i <= paraAmount; i++) {
			Document para = (Document) doc.get(Integer.toString(i));
			int stnAmount = para.getInteger("stnAmount");
			for (int j = 1; j <= stnAmount; j++) {
				String sentence = null;
				sentence = (String) para.get(Integer.toString(i));
				if(sentence == null)
					amount = 0;
				else
					amount += sentence.length();
			}
		}
		return amount;
	}
	/**
	 * 抄袭字数
	 * @param tx
	 * @return
	 */
	public static int plagiarizeCharsAmount(Text tx){
		return 0;
	}
}
